import * as api from '@/api/search';

export default {
  namespaced: true,
  state: {
    // 搜索建议列表
    list: [],
    // 搜索结果列表
    resultList: [],
  },
  mutations: {
    setList(state, newValue) {
      state.list = newValue;
    },
    setResultList(state, newValue) {
      state.resultList = newValue;
    },
  },
  actions: {
    async updateList (ctx, v) {
      const res = await api.getSuggestList(v);
      ctx.commit('setList', res);
    },
    async updateResultList (ctx, v) {
      const res = await api.getResultList(v);
      ctx.commit('setResultList', res);
    },
  },
}
